home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Hyper / Q-R / RPN Calculator.cpt / RPN Calculator / background_2751.txt < prev    next >
Text File  |  1988-09-16  |  3KB  |  112 lines

  1. -- background: 2751 from stack: in
  2. -- bmap block id: 2136
  3. -- flags: 4000
  4. -- background id: 0
  5. -- name: 
  6. ----- HyperTalk script -----
  7. on pushup
  8.   delete first line of card field Regs
  9. end pushup
  10.  
  11. on check
  12.   global flag
  13.   global invflg
  14.   if flag = 1 then
  15.     if line 4 of card field "Regs" <> "" then pushup
  16.     delete line 4 of card field "Regs"
  17.   end if
  18.   put 0 into flag
  19.   put 0 into invflg
  20. end check
  21.  
  22. on funcdrop
  23.   global flag
  24.   put card field "Regs" into temp
  25.   put line 2 of temp into line 3 of temp
  26.   put line 1 of temp into line 2 of temp
  27.   put temp into card field "Regs"
  28.   put 1 into flag
  29. end funcdrop
  30.  
  31. on arcsin
  32.   -- From "Software Manual for the Elementary Functions
  33.   -- by W. Cody and W. Waite (Prentice Hall, 1980)
  34.   global Result
  35.   global nform
  36.   global aflag
  37.   global error
  38.   set numberFormat to "0.000000000000000000000000"
  39.   put line 4 of card field "Regs" into x
  40.   put abs(x) into Y
  41.   if Y > .5 then
  42.     put 1 - aflag into i
  43.     if Y > 1 then
  44.       beep
  45.       put 1 into error
  46.       exit arcsin
  47.     end if
  48.     put (1-Y)/2 into g
  49.     put -2*sqrt(g) into Y
  50.     put R(g) * Y + Y into Result
  51.   else
  52.     put aflag into i
  53.     if Y < .000000001 then
  54.       put Y into Result
  55.     else
  56.       put Y*Y into g
  57.       put Y + Y * R(g) into Result
  58.     end if
  59.   end if
  60.   if aflag = 0 then
  61.     if i = 1 then
  62.       put .78539816339744830962 + Result + .78539816339744830962 into Result
  63.     end if
  64.     if x < 0 then
  65.       put -Result into Result
  66.     end if
  67.   else
  68.     if x < 0 then
  69.       if i = 0 then
  70.         put 1.57079632679489661923 + Result + 1.57079632679489661923 into Result
  71.       else
  72.         put .78539816339744830962 + Result + .78539816339744830962 into Result
  73.       end if
  74.     else
  75.       if i = 1 then
  76.         put .78539816339744830962 - Result + .78539816339744830962 into Result
  77.       else
  78.         put -Result into Result
  79.       end if
  80.     end if
  81.   end if
  82. end arcsin
  83.  
  84. function R g
  85. set numberFormat to "0.000000000000000000000000"
  86. put ((((-0.69674573447350646411*g + 10.152522233806463645)*g -39.688862997504877339)*g + 57.208227877891731407)*g -27.368494524164255994)*g into P
  87. put ((((g - 23.823859153670238830)*g + 150.95270841030604719)*g - 381.86303361750149284)*g + 417.14430248260412556)*g - 164.21096714498560795 into Q
  88. return P/Q
  89. end R
  90.  
  91. on doMenu task
  92.   if the userLevel = 5 then
  93.     pass doMenu
  94.   else
  95.     if task = "Print Report..." then pass doMenu
  96.     if task = "Compact Stack" then pass doMenu
  97.     if task = "Paste Button" then pass doMenu
  98.     if task = "Copy Button" then pass doMenu
  99.     if task = "Cut Text" then pass doMenu
  100.     if task = "Copy Text" then pass doMenu
  101.     if task = "Paste Text" then pass doMenu
  102.   end if
  103. end doMenu
  104.  
  105. on idle
  106.   if the userLevel = 5 then exit idle
  107.   hide menuBar
  108. end idle
  109.  
  110.  
  111.  
  112.